#pragma once
#include <sys/stat.h>

#include <fstream>
#include <iostream>
#include <mutex>
#include <string>

#include "json/json.h"
#include "mongoose/mongoose.h"

namespace CUitl {
bool file2json(std::string file, Json::Value &v);
bool str2file(std::string path, const std::string data);
bool str2json(std::string str, Json::Value &v);
std::string json2str(Json::Value &v, bool format = false);
uint64_t gettimestatmp();
uint64_t gettimestatmpms();
std::string timestamp2str(time_t t);
time_t str2timestamp(std::string time);
std::string GetSystemUuid();
void StringReplace(std::string &strBase, std::string strSrc,
                   std::string strDes);
std::string data2base64(const char *data, int size);
int base642data(std::string &str, char *data);
std::string url_encode(const char *data, int size);
size_t getfilesize(const std::string &file_name);
bool getfileexist(const std::string &file_name);
int GetRandomNum(int min, int max);
int SaveFile(const char *buff, int len, const char *filename);
// bool jpg2yuv(uint8_t *pSrcBuf, int size, uint8_t *pDstBuf, int *w, int *h);
bool AddDir(std::string dir);
extern std::mutex cuitlmutex_;
std::string GetMd5(const char *data, int len);
int fm_systembyvf(const char *cmdstring);
int fm_systembyio(const char *cmdstring,std::string &res);
};  // namespace CUitl